package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.Audit;
import com.ruoyi.system.vo.DriverAudit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.AuditMapper;
import com.ruoyi.system.service.IAuditService;

/**
 * 司机审核Service业务层处理
 *
 * @author yn第一深情
 * @date 2024-09-12
 */
@Service
public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements IAuditService {

    @Autowired
    private AuditMapper auditMapper;

    /**
     * 查询司机审核
     *
     * @param auditId 司机审核主键
     * @return 司机审核
     */
    @Override
    public Audit selectAuditByAuditId(Long auditId) {
        return auditMapper.selectAuditByAuditId(auditId);
    }

    /**
     * 查询司机审核列表
     *
     * @param audit 司机审核
     * @return 司机审核
     */
    @Override
    public List<Audit> selectAuditList(Audit audit) {
        return auditMapper.selectAuditList(audit);
    }


    @Override
    public List<DriverAudit> getAuditList(Audit audit) {
        return auditMapper.getAuditList(audit);
    }
    /**
     * 新增司机审核
     *
     * @param audit 司机审核
     * @return 结果
     */
    @Override
    public int insertAudit(Audit audit) {
                audit.setCreateTime(DateUtils.getNowDate());
            return auditMapper.insertAudit(audit);
    }

    /**
     * 修改司机审核
     *
     * @param audit 司机审核
     * @return 结果
     */
    @Override
    public int updateAudit(Audit audit) {
                audit.setUpdateTime(DateUtils.getNowDate());
        return auditMapper.updateAudit(audit);
    }

    /**
     * 批量删除司机审核
     *
     * @param auditIds 需要删除的司机审核主键
     * @return 结果
     */
    @Override
    public int deleteAuditByAuditIds(Long[] auditIds) {
        
            LambdaUpdateWrapper<Audit> wrapper;
            for (Long id : auditIds) {
                wrapper = Wrappers.lambdaUpdate(Audit.class)
                .eq(Audit::getAuditId, id)
                    .set(Audit::getDelFlag, "1");
                super.update(new Audit(), wrapper);
            }
            return 1;
    }

    /**
     * 删除司机审核信息
     *
     * @param auditId 司机审核主键
     * @return 结果
     */
    @Override
    public int deleteAuditByAuditId(Long auditId) {
        return auditMapper.deleteAuditByAuditId(auditId);
    }
}



